$(function(){
    let type=sessionStorage.getItem('type')
    switch(type){
        case '1':
           $('#borr').html('信用贷')
        break;
        case '2':
            $('#borr').html('车易贷')
         break;
         case '3':
            $('#borr').html('房易贷')
         break;
    }

    $('#btn').click(function(){
        let userid=sessionStorage.getItem('userid');
        let borrowType=sessionStorage.getItem('type');
        let borrowmoney=$('#borrowmoney').val();
        let interest=$('#interest').val();
        let borrowtime=$('#borrowtime option:selected').val();
        let repaytype=$('.repaytype').val();
        let minbid=$('#minbid').val();
        let bouns=$('#bouns').val();
        let days=$('#days option:selected').val();
        let title=$('#title').val();
        let info=$('#info').val();
        
        //console.log(userid,borrowType,borrowmoney,interest,borrowtime,repaytype,minbid,bouns,days,title,info);
        $.ajax({
            url:'http://139.9.177.51:3333/p2p/borrow',
            type:'post',
            data:{userid,borrowType,borrowmoney,interest,borrowtime,repaytype,minbid,bouns,days,title,info},
            dataType:'json',
            success:function(res){
               if(res.code==200){
                    alert('恭喜！借款成功')
                    location.href='./index.html'
               }else{
                alert('恭喜！借款成功')
               }
            }
        })
    })
})